package Utils.word;

import org.apache.poi.POIXMLDocument;
import org.apache.poi.POIXMLTextExtractor;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.junit.Test;


/**
 * Created by 隼 on 2017/6/2.
 * Java word 读取word文件
 */
public class test1 {
    @Test
    public  void test(){
        try {


            OPCPackage opcPackage = POIXMLDocument.openPackage("C:\\Users\\隼\\Desktop\\test.docx");
            POIXMLTextExtractor extractor = new XWPFWordExtractor(opcPackage);
            String text2007 = extractor.getText();
            System.out.println(text2007);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
